/*
 * HelpFrame.java
 *
 * Created on 13 juni 2008, 19:47
 */

package com.laamella.syntherface.synths.alesis.micron.gui;

import java.util.ArrayList;
import java.util.List;

import com.laamella.syntherface.synths.events.EventListener;
import com.laamella.syntherface.synths.models.HasModel;
import com.laamella.syntherface.synths.models.ListTableModel;
import com.laamella.syntherface.synths.models.ParameterModel;

/**
 * 
 * @author danny
 */
public class HelpFrame extends javax.swing.JFrame implements EventListener<ParameterModel> {

	private List<ParameterModel> parameterList = new ArrayList<ParameterModel>();

	/** Creates new form HelpFrame */
	public HelpFrame() {
		initComponents();
		parameterTable.setModel(new ListTableModel<ParameterModel>(parameterList) {

			@Override public Object getValueFrom(ParameterModel item, int column) {
				switch (column) {
				case 0:
					return item.getMidiDoc();
				case 1:
					return item.name;
				case 2:
					return item.getMinimum();
				case 3:
					return item.getMaximum();
				}
				return null;
			}

			private final String[] ColumnNames = new String[] { "MIDI", "Name", "Minimum", "Maximum" };

			@Override public String[] getColumnNames() {
				return ColumnNames;
			}
		});
	}

	@Override public void onEvent(ParameterModel parameter) {
		parameterList.add(parameter);
	}

	/**
	 * This method is called from within the constructor to initialize the
	 * form. WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")// <editor-fold defaultstate="collapsed"
	// desc="Generated
	// Code">//GEN-BEGIN:initComponents
	private void initComponents() {

		jScrollPane1 = new javax.swing.JScrollPane();
		parameterTable = new javax.swing.JTable();
		jLabel1 = new javax.swing.JLabel();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		setTitle("Help on the Micron");

		parameterTable.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {

		}, new String[] { "midi", "name", "minimum", "maximum" }) {
			Class[] types = new Class[] { java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class };

			public Class getColumnClass(int columnIndex) {
				return types[columnIndex];
			}
		});
		jScrollPane1.setViewportView(parameterTable);

		jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		jLabel1.setText("Parameters");

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				layout.createSequentialGroup().addContainerGap().addGroup(
						layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jScrollPane1,
								javax.swing.GroupLayout.DEFAULT_SIZE, 813, Short.MAX_VALUE).addComponent(jLabel1))
						.addContainerGap()));
		layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				layout.createSequentialGroup().addContainerGap().addComponent(jLabel1).addPreferredGap(
						javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jScrollPane1,
						javax.swing.GroupLayout.DEFAULT_SIZE, 545, Short.MAX_VALUE).addContainerGap()));

		pack();
	}// </editor-fold>//GEN-END:initComponents

	/**
	 * @param args
	 *                the command line arguments
	 */
	public static void main(String args[]) {
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				new HelpFrame().setVisible(true);
			}
		});
	}

	// Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JLabel jLabel1;
	private javax.swing.JScrollPane jScrollPane1;
	private javax.swing.JTable parameterTable;
	// End of variables declaration//GEN-END:variables

}
